#ifndef BC_WEIR_FUNCS_HPP
#define BC_WEIR_FUNCS_HPP

#include "typeAliases.hpp"

namespace hms::bc_weir
{


scalar pressureFactor( scalar slopeAngle );


template<typename OutType, typename DType, typename VType>
void waterDepth_edge(
	Eigen::DenseBase<OutType>& d_e,
	const Eigen::DenseBase<DType>& d,
	const Eigen::DenseBase<VType>& vOrth,
	scalar cp
){
	assert( d_e.size() == d.size() );
	assert( d_e.size() == vOrth.size() );
	/* write Froude squares first, then go from there */
	auto& fr { d_e.derived() };
	fr = vOrth.derived().square() / ( phys::g * d.derived() );

	d_e =
		- sqrt( (4 + 8*fr) / (3*cp) ) *
		cos(
			acos( -3 * sqrt(3.) * sqrt(cp) * fr / (1 + 2*fr).pow(1.5) ) / 3.
			+ math::pi / 3
		) * d.derived();
}

} // namespace hms


#endif